<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>人才库</el-breadcrumb-item>
      <el-breadcrumb-item>人才库列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>

      <!-- 表格区域 -->
      <el-table :data="userList" border stripe>
        <el-table-column type="expand">
          <template slot-scope="scope">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="名称：">
                <span>{{ scope.row.name }}</span>
              </el-form-item>
              <el-form-item label="出生日期：">
                <span>{{ scope.row.birth }}</span>
              </el-form-item>
              <el-form-item label="性别：">
                <span>{{ scope.row.gender }}</span>
              </el-form-item>
              <el-form-item label="籍贯：">
                <span>{{ scope.row.nativePlace }}</span>
              </el-form-item>
              <el-form-item label="身高：">
                <span>{{ scope.row.height }}</span>
              </el-form-item>
              <el-form-item label="学历：">
                <span>{{ scope.row.education }}</span>
              </el-form-item>
              <el-form-item label="手机：">
                <span>{{ scope.row.phone }}</span>
              </el-form-item>
              <el-form-item label="邮箱：">
                <span>{{ scope.row.email }}</span>
              </el-form-item>
              <el-form-item label="意向岗位：">
                <span>{{ scope.row.wish }}</span>
              </el-form-item>
              <el-form-item label="工作经历：">
                <span>{{ scope.row.experience }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>        
        <el-table-column label="名称" prop="name"></el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        layout="total, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      total: 0,
      pageNum: 1,
      userList: []
    }
  },
  created() {
    this.getUserList()
  },
  methods: {
    async getUserList() {
      const { data: res } = await this.$http.get('user', {
        params: {
          pageSize: 10,
          pageNum: this.pageNum
        }
      })
      if (res.meta.status != 200) {
        return this.$message.error('获取人才库列表失败！')
      }
      this.userList = res.data.list
      this.total = res.data.total
    },
    handleCurrentChange(newPage) {
      this.pageNum = newPage
      this.getUserList()
    }
  }
}
</script>

<style lang="less" scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>